﻿/*********************************************************************************
**                                                                              **
**  Copyright (C) 2022-2022 LiLong                                              **
**  This file is part of BluetoothCpp.                                          **
**                                                                              **
**  BluetoothCpp is free software: you can redistribute it and/or modify        **
**  it under the terms of the GNU Lesser General Public License as published by **
**  the Free Software Foundation, either version 3 of the License, or           **
**  (at your option) any later version.                                         **
**                                                                              **
**  BluetoothCpp is distributed in the hope that it will be useful,             **
**  but WITHOUT ANY WARRANTY; without even the implied warranty of              **
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               **
**  GNU Lesser General Public License for more details.                         **
**                                                                              **
**  You should have received a copy of the GNU Lesser General Public License    **
**  along with BluetoothCpp.  If not, see <https://www.gnu.org/licenses/>.      **
**********************************************************************************/
#pragma once

#include "../Address.h"
#include "../Typedefs.h"
#include "../Uuid.h"

#include <chrono>

namespace BTH
{
class AbstractPlatformSocket
{
public:
    AbstractPlatformSocket() {}
    AbstractPlatformSocket(Handle handle) {}
    virtual void connect(const Address& addr, const Uuid& uuid) = 0;
    virtual bool isConnected() const { return m_connected; }
    virtual void send(const char* buffer, int size)                    = 0;
    virtual void close()                                               = 0;
    virtual std::string read(int maxSize)                              = 0;
    virtual Handle handle() const                                      = 0;
    virtual void setSendTimeout(const std::chrono::milliseconds& msec) = 0;
    virtual void setRecvTimeout(const std::chrono::milliseconds& msec) = 0;

protected:
    bool m_connected { false };
};
} // namespace BTH
